package cn.iocoder.yudao.module.agri.dal.mysql.farmrecord;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.agri.dal.dataobject.farmrecord.FarmRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.agri.controller.admin.farmrecord.vo.*;

/**
 * 农事记录 Mapper
 *
 * @author 广东小蜂
 */
@Mapper
public interface FarmRecordMapper extends BaseMapperX<FarmRecordDO> {

    default PageResult<FarmRecordDO> selectPage(FarmRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FarmRecordDO>()
                .eqIfPresent(FarmRecordDO::getPlanId, reqVO.getPlanId())
                .eqIfPresent(FarmRecordDO::getFarmingType, reqVO.getFarmingType())
                .betweenIfPresent(FarmRecordDO::getFarmingDate, reqVO.getFarmingDate())
                .eqIfPresent(FarmRecordDO::getOverseer, reqVO.getOverseer())
                .orderByDesc(FarmRecordDO::getId));
    }

    default List<FarmRecordDO> selectList(FarmRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FarmRecordDO>()
                .eqIfPresent(FarmRecordDO::getPlanId, reqVO.getPlanId())
                .eqIfPresent(FarmRecordDO::getFarmingType, reqVO.getFarmingType())
                .betweenIfPresent(FarmRecordDO::getFarmingDate, reqVO.getFarmingDate())
                .eqIfPresent(FarmRecordDO::getOverseer, reqVO.getOverseer())
                .orderByDesc(FarmRecordDO::getId));
    }

}
